home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1992 August
/
info-mac-1992.iso
/
Language (lang)
/
Lazy-Scheme
/
start
< prev
Wrap
Text File
|
1978-01-04
|
3KB
|
103 lines
(define (system:quasiquote s)
(cond (null? s) ()
(atom? s) (list 'quote s)
(eq? (0 s) 'unquote) (1 s)
(cons? (0 s)) (cond (eq? (0 (0 s)) 'unquote-splicing)
(if (null? (-1 s)) (1 (0 s))
(list 'append (1 (0 s)) (system:quasiquote (-1 s))))
† (list 'cons (system:quasiquote (0 s))
(system:quasiquote (-1 s))))
† (list 'cons (system:quasiquote (0 s))
(system:quasiquote (-1 s)))))
(defmacro (quasiquote s) (system:quasiquote s))
(defmacro (unquote | s) 'unquote)
(defmacro (unquote-splicing | s) 'unquote-splicing)
(defmacro (defext fic seg nom xref str | arg)
`(begin (define (,nom ,@arg))
(coerce ,nom 13)
(force (car=! ,nom (getext ,xref ,seg ,fic)))
(coerce ,nom 12)
(setstrict ,nom ,str) ',nom))
(defmacro (kappa | l)
`(setstrict (lambda ,@l) %1111111111111111))
(defmacro (defkap f | b)
(cond (cons? f) `(define ,(0 f) (setstrict (lambda ,(-1 f) ,@b) %1111111111111111))
`(define ,f ,@b)))
(define (append l1 l2)
(cond (null? l1) l2
(cons (0 l1) (append (-1 l1) l2))))
(define (reverse l | bag)
(cond (null? l) bag
(apply reverse (cons (-1 l)(cons (0 l) bag)))))
(defkap (memq? o l)
(cond (null? l) ƒ
(eq? o (0 l)) l
(memq? o (-1 l))))
(defkap (mem=? o l)
(cond (null? l) ƒ
(=? o (0 l)) l
(mem=? o (-1 l))))
(defkap (equal? l1 l2)
(cond (=? l1 l2) †
(cons? l1)(and (cons? l2)(equal? (0 l1)(0 l2))(equal? (-1 l1)(-1 l2)))))
(defkap (member? o l)
(cond (null? l) ƒ
(equal? o (0 l)) l
(member? o (-1 l))))
(defkap (nequal? l1 l2)
(not (equal? l1 l2)))
(defkap (union l1 l2)
(cond (<? (0 l1)(0 l2))(cons (0 l1) (union (-1 l1) l2))
(=? (0 l1)(0 l2))(cons (0 l1)(union (-1 l1)(-1 l2)))
(cons (0 l2) (union l1 (-1 l2)))))
(defkap (inter l1 l2)
(cond (<? (0 l1)(0 l2)) (inter (-1 l1) l2)
(=? (0 l1)(0 l2))(cons (0 l1)(inter (-1 l1)(-1 l2)))
(inter l1 (-1 l2))))
(defkap (diff l1 l2)
(cond (=? (0 l1)(0 l2)) (diff (-1 l1) l2)
(<? (0 l1)(0 l2)) (cons (0 l1) (diff (-1 l1) l2))
(diff l1 (-1 l2))))
(define (map f | l)
(amap f l))
(defkap (amap f l)
(cond (atom? f)(apply f l)
(cons (amap (0 f) (allcar l))
(amap (-1 f) (allcdr l)))))
(defkap (allcar l)
(cond (null? l) ()
(cons (0 (0 l)) (allcar (-1 l)))))
(defkap (allcdr l)
(cond (null? l) ()
(cons (-1(0 l)) (allcdr (-1 l)))))
(define (consif kar kdr)
(cond kar (cons kar kdr)
kdr))
(define (reduce f b l)
(cond (null? l) b
(f (0 l) (reduce f b (-1 l)))))
(define (suchas p f)
(cond (p (0 f)) (cons (0 f) (suchas p (-1 f)))
(suchas p (-1 f))))